<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //json数据
//                  {
//   "name": "唐玮",
//   "data": {
//     "grade": 58
//          }
//      }
  
let user={
  "name": "唐玮",
  "data": {
    "grade": 58,
 
         }
     
     }

     let json=JSON.stringify(user,null,2);
console.log(json);
     //将json转换为对象，再将属性为name的改为唐家辉
let to_obj=JSON.parse(json,(key,value)=>{
   
    if(key=="name"){
        value="唐家辉";
    }
   
  
    return value;
})  ;
console.log(to_obj);
    </script>
</body>
</html>